{% if page_obj.has_other_pages %}
<div class="pagination">
<ul>
{% if page_obj.has_previous %}
    <li><a href="?page={{ page_obj.previous_page_number }}">Previous</a></li>
{% else %}
    <li><a href="#" class="prevnext disablelink">Previous</a></li>    
{% endif %}
{% for page in page_obj.paginator.page_range %}
    <li><a href="?page={{ page }}">{{ page }}</a></li>
{% endfor %}
{% if page_obj.has_next %}
    <li><a href="?page={{ page_obj.next_page_number }}">Next</a></li>
{% else %}
<li>
    <a href="#" class="prevnext disablelink">Next</a>
</li>
{% endif %}
</ul>
</div>
{% endif %}